<template>

  <div :data="MyData">
    <template v-if="scope.row.thumbup">
      <el-button icon="el-icon-thumb"
                 type="success"
                 :disabled="idUser == 0"
                 round
                 @click="deleteCommentThumbsup(scope.row)"></el-button>
    </template>
    <template v-else>
      <el-button icon="el-icon-thumb"
                 type="primary"
                 round
                 :disabled="idUser == 0"
                 @click="CommentThumbsup(scope.row)"></el-button>
    </template>
  </div>

</template>

<script>
export default {
  methods: {
    deleteCommentThumbsup (commentObj) {
      // console.log(commentObj, "取消点赞")
      let that = this
      this.$axios({
        headers: { 'content-Type': 'application/json;charset=utf-8' },
        method: 'delete',
        url: "news/deletenewscommentthumbup",
        params: {

          idNewsComment: commentObj.idNewsComment,
          idUser: this.idUser

        }
      })
        .then(
          response => {

            // console.log('取消点赞成功', response.data)
            that.commentContent = ''
            this.$notify({
              title: '成功',
              message: response.data.msg,
              type: 'success'
            });
            // commentObj.thumbup = true

            that.$emit("notifyFather", true)
          }
        )
        .catch(function (error) {
          // console.log(error);
          that.$notify({
            title: '错误',
            message: response.data.msg,
            type: 'error'
          });
        });

    },
    CommentThumbsup (commentObj) {
      // console.log(commentObj, "点赞")
      let that = this
      this.$axios({
        headers: { 'content-Type': 'application/json;charset=utf-8' },
        method: 'post',
        url: "news/insertnewscommentthumbup",
        params: {

          idNewsComment: commentObj.idNewsComment,
          idUser: this.idUser

        }
      })
        .then(
          response => {

            // console.log('点赞成功', response.data)
            that.commentContent = ''
            this.$notify({
              title: '成功',
              message: response.data.msg,
              type: 'success'
            });
            // commentObj.thumbup = true

            that.$emit("notifyFather", true)
          }
        )
        .catch(function (error) {
          // console.log(error);
          that.$notify({
            title: '错误',
            message: response.data.msg,
            type: 'error'
          });
        });

      // this.isThumbsup = true

    },
  }
}
</script>